05. Objects in Apps

Objects in Apps

Object-oriented programming, as the name implies, relies on the concept of objects. Recall that objects are a way to organize data and functionality into something we can use as programmers. Also, relationships describe how objects are connected and used together within a system. Most importantly, Swift was designed with object-oriented programming in mind—so you'll be using objects!

Up to this point, we’ve examined objects and relationships in the Maze app, but what about real-world apps? In the upcoming exercises, we'll take a look at a few examples.

Objects in Airbnb

Prepare

The first app we are going to look at is Airbnb. Airbnb is a trusted community marketplace for people to list, discover, and book unique accommodations around the world, and it services millions of users from all over the world. Below are a few screens from the Airbnb app for the iPhone:

Airbnb lets users book accommodations from around the world.

Airbnb lets users book accommodations from around the world.

On the first screen, we notice a list of popular travel destinations. Then, when a destination is selected, we see that a destination can consist of many rooms. Also, there are some screens that provide details about a single room. Those screens show information like the room's host and its ratings. These are all great insights!

By just observing a few images, we've already identified four potential objects (destinations, rooms, hosts, ratings) and relationships in the Airbnb app. This process of breaking a large object like Airbnb into smaller pieces is sometimes referred to as decomposition or "object decomposition".

Learn

QUESTION:

As an exercise, continue this process and create an object diagram for the Airbnb app. Use the image above or even download/use the app to get an idea of the objects and relationships that might exist in Airbnb. Keep in mind that there is no perfect answer. Just add as much detail as you can. More detail is highly encouraged!

When you're done with your diagram, reflect on what object you think might be the most complex and why. Once you've submitted your answer, you'll be able to compare your diagram with ours!

ANSWER:

One of the more complex objects might be the Booking. This object needs to be able to relay information about the User making the reservation as well as all the Room itself.

Here is the diagram we created for Airbnb:

Airbnb Object Diagram

QUESTION:

What do you notice about our object diagram compared to yours? You must answer the previous question to see our object diagram.

Are there any similarities? Any differences? Is there anything that should be added to the diagram? Does this diagram give you an idea of how the app is built?

ANSWER:

Thanks for sharing!

Objects in Blue Apron

Prepare

The next app we are going to look at is Blue Apron. Blue Apron is an app tailored for home cooks who want fresh ingredients delivered to their door. It also features simple, seasonal recipes, cooking instructions, tips, and a marketplace for purchasing cooking equipment.

Blue Apron is a great app for home cooks.

Blue Apron is a great app for home cooks.

Again, if you would like, try downloading and using the Blue Apron app to get a better idea of how it works.

Learn

QUESTION:

Just like you did with Airbnb, create an object diagram that identifies some of the objects and relationships in Blue Apron. Keep in mind that there is no perfect answer. Just add as much detail as you can. More detail is highly encouraged!

When you're done with your diagram, reflect on what you think might be the most complex object and why. Once you've submitted your answer, you'll be able to compare your diagram with ours!

ANSWER:

For Blue Apron, we think the Recipe is the most complex object. From our diagram, it has the most relationships with other objects and it is one of the core feature of Blue Apron. Logistically speaking, the Delivery and Ingredient objects are quite complex, too. Somehow, Blue Apron must coordinate with a packaging and shipping facility to box up Ingredients to send to its users' doors!

Here is the diagram we created for Blue Apron:

Blue Apron Object Diagram

QUESTION:

What do you notice about our object diagram compared to yours? You must answer the previous question to see our object diagram.

Are there any similarities? Any differences? Is there anything that should be added to the diagram? Does this diagram give you an idea of how the app is built?

ANSWER:

Thanks for sharing!

Objects in Forest Home

Prepare

For our last exercise, let’s take a look at the game Forest Home. Forest Home is a popular kids game that challenges users to guide forest animals back to their homes.

Forest Home is a puzzle game that focuses on path-building.

Forest Home is a puzzle game that focuses on path-building.

This time if you don’t have an iOS device readily available, there is a trailer you can watch to get an idea of the game.

Learn

QUESTION:

As with the previous two exercises, build a diagram representing the objects and structures in Forest Home. When you are finished, post an image of your favorite diagram in the forums.

Keep in mind that there is no perfect answer. Just add as much detail as you can. More detail is highly encouraged!

When you're done with your diagram, reflect on what object you think might be the most complex and why. Once you've submitted your answer, you'll be able to compare your diagram with ours!

ANSWER:

Forest Home is all about the Puzzles, and from our object diagram they appear quite complex. Each Puzzle has a Grid, contains multiple Paths, Animals (Friend or Enemy), and a Score.

Here is the diagram we created for Forest Home:

Forest Home Object Diagram

QUESTION:

What do you notice about our object diagram compared to yours? You must answer the previous question to see our object diagram.

Are there any similarities? Any differences? Is there anything that should be added to the diagram? Does this diagram give you an idea of how the app is built?

ANSWER:

Thanks for sharing!

Closing Statements